
package org.sopt.dev.ImgKnight.frontier.Queue;

import java.net.URL;
import java.util.concurrent.ConcurrentLinkedQueue;

public class SiteMapList {

	private ConcurrentLinkedQueue<URL> queue = null;
	
	private long hostHashValue = -1;
	
	private String countryCode = null;

	private String countryName = null;
	
	private long lastPopupTimeMillis = -1;
	
	public SiteMapList(long hostHashValue, String countryCode, String countryName) throws IllegalArgumentException {
		if( countryCode == null )
			throw new IllegalArgumentException("contryCode is null");
		if( countryName == null )
			throw new IllegalArgumentException("countryName is null");
		queue = new ConcurrentLinkedQueue<URL>();
		this.hostHashValue = hostHashValue;
		this.countryCode = countryCode;
		this.countryName = countryName;
		lastPopupTimeMillis = 0;
	}
	
	public void offer(URL url) {
		queue.offer(url);
	}
	
	public URL peek() {
		return queue.peek();
	}
	
	public URL poll() {
		URL url = queue.poll();
		lastPopupTimeMillis = System.currentTimeMillis();
		return url;
	}

	public long interval(long now) {
		return Math.abs(lastPopupTimeMillis - now);
	}
	
	public int size() {
		return queue.size();
	}
	
	public boolean isEmpty() {
		return queue.isEmpty();
	}
	
	public long getLastPopupTimeMillis() {
		return lastPopupTimeMillis;
	}
	
	public long getHostHashValue() {
		return hostHashValue;
	}
	public String getCountryCode() {
		return countryCode;
	}

	public String getCountryName() {
		return countryName;
	}
	
}
